Interactive Map and Chloropleth visualizations.
The Office of Spill Prevention and Response (OSPR) incident Tracking database provides data on the occurrence and location of marine and inland oil spills. An incident is classified as an oil spill if there is discharge or there is potential for discharge of deletious materials.
Data is provided by Oil Spill Incident Tracking [ds394]. (n.d.). Retrieved February 17, 2021, from https://gis.data.ca.gov/datasets/7464e3d6f4924b50ad06e5a553d71086_0/data
# reading in the county data from shapefile in order to make a map
ca_counties <- read_sf(here("oil_blog_post", "ca_counties"), layer = "CA_Counties_TIGER2016") %>%
clean_names() %>%
select(name)
# st_crs(ca_counties) , checked the coordinate system, commented it out for sake of cleanness
#reading in the oil spill data
oil_data <- read_sf(here("oil_blog_post","oil_data"), layer = "Oil_Spill_Incident_Tracking_%5Bds394%5D") %>%
clean_names()
# st_crs(oil_data)
# making sure the two data sets are set to the same crs
ca_counties <- st_transform(ca_counties, st_crs(oil_data))
tmap_mode("view")
#need to find count of oil spills in each CA county.
# Step 1- join te data sets (since we already set the coordinate systems to match)
oil_county <- ca_counties %>%
st_join(oil_data)
#step 2: getting the counts
oil_counts <- oil_county %>%
count(name)
# making the chloropleth
ggplot(data = oil_counts) +
geom_sf(aes(fill = n), color = "white", size = 0.1) +
scale_fill_gradientn(colors = c("lightblue", "blue", "navyblue")) +
theme_minimal()+
labs( fill = "Oil Spills")
Figure 1: Figure 1.0: Distribution of Oil Spills that occured in 2008 by county. As color gradient darkens, the number of oil spills increases per county